package io.gitee.zhangbinhub.acp.core.file.pdf

import com.itextpdf.text.pdf.PdfWriter
import io.gitee.zhangbinhub.acp.core.common.exceptions.EnumValueUndefinedException

enum class PermissionType(val value: Int) {
    ALLOW_ASSEMBLY(PdfWriter.ALLOW_ASSEMBLY), ALLOW_COPY(
        PdfWriter.ALLOW_COPY
    ),
    ALLOW_DEGRADED_PRINTING(
        PdfWriter.ALLOW_DEGRADED_PRINTING
    ),
    ALLOW_FILL_IN(PdfWriter.ALLOW_FILL_IN), ALLOW_MODIFY_ANNOTATIONS(
        PdfWriter.ALLOW_MODIFY_ANNOTATIONS
    ),
    ALLOW_MODIFY_CONTENTS(PdfWriter.ALLOW_MODIFY_CONTENTS), ALLOW_PRINTING(
        PdfWriter.ALLOW_PRINTING
    ),
    ALLOW_SCREEN_READERS(PdfWriter.ALLOW_SCREENREADERS);

    companion object {
        private var map: MutableMap<Int, PermissionType> = mutableMapOf()

        init {
            for (type in entries) {
                map[type.value] = type
            }
        }

        @JvmStatic
        @Throws(EnumValueUndefinedException::class)
        fun getEnum(value: Int): PermissionType {
            if (map.containsKey(value)) {
                return map[value]!!
            }
            throw EnumValueUndefinedException(PermissionType::class.java, value.toString() + "")
        }
    }
}
